<template>
	<view  style="display: flex;margin:0 auto;flex-direction: column; width: 749rpx;">
		<!-- 最上面的教室选择 -->
		<u-tabs  style="height: 80rpx;" :current="current" :list="xiaoqu" 
			scroll-y="true" lineWidth="50" lineColor="blue"
			:activeStyle="{ color: 'blue',  transform: 'scale(1)'}"
			:inactiveStyle="{color: '#606266',transform: 'scale(1)'}"
			itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;" @change="change">
		</u-tabs>
		
		<!-- 管理教室 -->
		<view v-for="(item,index) in jiaoshilist"  :key=index  style="display: flex;flex-direction: row;padding: 0 20rpx; align-items: center;justify-content: space-around;" >
			<view  style="display: flex;border-radius: 20rpx; width: 90%;background-color: white;box-shadow: 1px 1px 5px #c2c2c2;margin: 20rpx 0 0 20rpx;padding: 20rpx;justify-content: space-between;align-items: center;">
				<view style="display: flex;flex-direction: column;">
					<view >
						{{item.name}}
						<text style="font-size: 25rpx;color: #c2c2c2;">--{{item.weizhi}}</text>
					</view>
					<view style="display: flex;flex-direction: row; color: #c2c2c2;font-size: 28rpx;">
						<view class="">
							{{item.guanlilaoshi}}
						</view>
						<view style="margin-left: 20rpx;">
							Tel：{{item.guanlilaoshidianhua}}
						</view>
					</view>
				</view>
				<view style="display: flex;color: #c2c2c2;font-size: 28rpx;" @click="paike(item)">
					排课>>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import toast from '../../uni_modules/uview-ui/libs/config/props/toast'
	export default {
		data() {
			return {
				wodexiaoqu:[],//我能管理的校区
				jiaoshilist:[],
				xiaoqu:[],
				shu1:[],
				current:0,
			}
		},
		async onLoad() {
			this.xiaoqufun()
		},
		methods: {
			// 获取校区的信息
			async xiaoqufun(){
				const xiaoqu=await uni.getStorageSync('aoyashengxiaoqu')
				this.xiaoqu=[]
				let arr=[]
				for(var i=0;i<xiaoqu.result.data.length;i++){
					this.xiaoqu.push(xiaoqu.result.data[i])
					arr.push(xiaoqu.result.data[i].name)
				}
				this.wodexiaoqu=arr
				if(this.xiaoqu.length>1){
					this.xiaoqu.unshift ({
						name:'全部'
					})	
				}else{
					this.shu3=this.xiaoqu[0].name
				}	
				this.shu1=this.wodexiaoqu
				this.jiaoshilistfun()
			},
			//获取所选择校区的教室列表
			jiaoshilistfun(){
				uni.showLoading({
					title: '加载中……',
					mask: true
				});
				uniCloud.callFunction({
					name:"funshare",
					data:{
						leixing:23,//类型为23时，获取所选择校区的教室列表
						weizhi:this.shu1,
					}
				}).then(res=>{
					this.jiaoshilist=res.result.data
					uni.hideLoading();

				})
			},
			// 进入排课的界面
			paike(e){
				console.log('==',e)
				uni.setStorageSync('aoyashengjiaoshi',e)
				uni.navigateTo({
					url: "/pages/jiaoshi4a/jiaoshi4a"
				})
			},
			change(e){
				this.shu1=[]
				if(e.name=='全部'){
					this.shu1=this.wodexiaoqu
				}else{
					this.shu1.push(e.name)
				}
				this.jiaoshilistfun()
			},
	}
	}
</script>

<style>

</style>
